<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOpenShopUserContract extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('open_shop_user_contract', function (Blueprint $table) {
            $table->id();

            $table->string('orderNo', 60)->default('')->comment('订单号');
            $table->string('contractExtNo', 60)->default('')->comment("第三方合同编号");
            $table->tinyInteger('contractors')->default(0)->comment("签约主题  0 ： 个人 1 ： 公司");

            $table->string('companyName', 48)->default('')->comment("公司名称");
            $table->string('businessLicenseNumber', 48)->default('')->comment("营业执照号");
            $table->string('address', 255)->default('')->comment("公司地址");

            $table->unsignedInteger('startTime')->default(0)->comment('合同开始时间');
            $table->unsignedInteger('endTime')->default(0)->comment('合同截止时间');

            $table->tinyInteger('contractType')->default(0)->comment("签约类型  0 ： 新店加盟 1 ： 老店裂变");

            $table->unsignedInteger('policyTemplateId')->default(0)->comment('政策模版id');

            $table->text('remark')->nullable(true)->comment('内部备注');

            $table->unsignedTinyInteger('year')->default(0)->comment('合同年限');
            $table->unsignedInteger('initialFee')->default(0)->comment('加盟费');
            $table->unsignedInteger('technologyTransferFee')->default(0)->comment('技术转让费');
            $table->unsignedInteger('deposit')->default(0)->comment('保证金');
            $table->unsignedInteger('managementCost')->default(0)->comment('特许权使用费第一年');
            $table->unsignedInteger('decorationDeposit')->default(0)->comment('装修保证金');
            $table->tinyInteger('shopCount')->default(0)->comment('店铺数量');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->collation = 'utf8mb4_general_ci';
            $table->unique(['orderNo'], 'idx_orderNo');
            $table->comment = '招商加盟 - 合同';
        });

        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `open_shop_user_contract` AUTO_INCREMENT = 3000;");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('open_shop_user_contract');
    }
}
